<template>
  <PurchOrderDetail
    v-if="detailsInfo.visible && tableRow.orderType === 0"
    v-model:visible="detailsInfo.visible"
    :orderId="detailsInfo.orderId"
    @returnBack="returnBack"
  />
  <PurchReturnDetail
    v-if="detailsInfo.visible && tableRow.orderType === 1"
    v-model:visible="detailsInfo.visible"
    :purchReturnId="detailsInfo.orderId"
    @returnBack="returnBack"
  />
  <TransferOrderDetail
    v-if="detailsInfo.visible && tableRow.orderType === 2"
    v-model:visible="detailsInfo.visible"
    :table-row="detailsInfo.data"
    @returnBack="returnBack"
  />
  <receiving-order-detail
    v-if="detailsInfo.visible && tableRow.orderType === 15"
    v-model:visible="detailsInfo.visible"
    :id="detailsInfo.id"
    :is-cargo-space-manage="tableRow.isCargoSpaceManage"
    @returnBack="returnBack"
  />
</template>
<script setup name="freezeDetail">
import ReceivingOrderDetail from '@/views/stock/receiving/detail'
import TransferOrderDetail from '@/views/stock/transfer/detail'
import PurchOrderDetail from '@/views/purch/order/detail'
import PurchReturnDetail from '@/views/purch/return/detail'
const { proxy } = getCurrentInstance()
const emits = defineEmits()
const props = defineProps({
  tableRow: {
    type: Object,
    default: () => {
      return {}
    },
  },
  visible: {
    type: Boolean,
    default: false,
  },
})
const detailsInfo = ref({
  data: {},
  visible: false,
  id: '',
  orderId: '',
})
watch(
  () => props.visible,
  (val) => {
    console.log(val)
    if (val) {
      detailsInfo.value.visible = true
      detailsInfo.value.data = { id: props.tableRow.orderId }
      detailsInfo.value.id = props.tableRow.orderId
      detailsInfo.value.orderId = props.tableRow.orderId
    }
  },
  {
    deep: true,
  }
)
function returnBack() {
  emits('returnBack', false)
}
</script>
